<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--<script src="/js/jquery.js"></script>-->
</head>
<body>
<br>

<form class="form-horizontal" onsubmit="return valid_submit1()" id="form_register" method="post">
<!--<form class="form-horizontal" id="form_register" method="post">-->
    <div class="form-group">
        <div class="col-sm-10">
            <input name="name" type="text" class="form-control" id="inputEmail3" placeholder="账号:"/>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-10">
            <input name="password" type="password" class="form-control" id="inputPassword3" placeholder="密码:"/>
        </div>
    </div>

    <div class="form-group">
        <div class="col-sm-10">
            <input name="repassword" type="password" class="form-control" id="reinputPassword3" placeholder="确认密码:"/>
        </div>
    </div>


    <div class="form-group">

        <div class="col-sm-10">
            <input name="nickname" type="text" class="form-control" id="" placeholder="昵称:"/>
        </div>
    </div>

    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">

            <!--<input type="submit" class="btn btn-default" value="注册">-->
            <input type="button" class="btn btn-default" onclick="register_btn();valid_submit1()" value="注册">
            <input type="button" id="btn_back" class="btn btn-default" value="返回">
        </div>
    </div>
</form>

<script>
    $(document).ready(function () {
        $('#btn_back').click(function () {
            $('#viewDiv').load('login.html')
        })
    })

    function valid_submit1() {
        var name = $("input[name='name']").val();
        var password = $("input[name='password']").val();
        var repassword = $("#reinputPassword3").val();
        if (name != "" && password != "" && password == repassword) {
            return true;
        } else {
            return false;
        }
    }

    function register_btn() {
        $('#form_register').ajaxSubmit({
            type: "post",
            url: "/user/register",
            success: function (data) {
                if (data) {
                    //登录成功
                    alert("恭喜你,注册成功!")
                } else {
                    //登录失败
                    alert('注册失败,用户已存在');
                }
                 window.location.href = "zhuye.html";
            }
        })
    }
</script>

</body>
</html>